/**
 * 
 */
package com.revenco.bi.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.revenco.bi.controller.basecontroller.AbstractUserAwareController;
import com.revenco.bi.model.userbean.AnychartDataBean;
import com.revenco.bi.service.ChartSqlPieceService;
import com.revenco.bi.service.ChartSqlService;

/**
 * @author LingJun
 * @version $Revision:1.0.0, 2014年1月17日 下午3:32:08
 */
@Controller
public class ChartSql extends AbstractUserAwareController {
	@Autowired
	ChartSqlService chartSqlService2;
	@Autowired
	private ChartSqlPieceService chartSqlService;
	@RequestMapping(value = "/browseSql4Pic",produces="text/plain;charset=UTF-8")
	@ResponseBody
	public String browseSql4Pic(@RequestParam("CFields") String CFields,
			@RequestParam("XFields") String XFields,
			@RequestParam("YFields") String YFields,
			String mulRelationData) throws Exception {
		log.info("buildFullSelectJson: {}", XFields);
		String sql = chartSqlService.spliceSql(CFields, XFields, YFields, mulRelationData);
		return sql;
		// "{'success':true,'sql':'SELECT t.tablename FROM TABLETEST t GROUP BY t.tablename ORDER BY t.id DESC'}";
	}

	@RequestMapping(value = "/getSeriesData")
	@ResponseBody
	public Map<String, List<AnychartDataBean>> getSeriesData(
			@RequestParam("CFields") String CFields,
			@RequestParam("XFields") String XFields,
			@RequestParam("YFields") String YFields,
			String mulRelationData) throws Exception {
		return chartSqlService.getSeriesData(CFields, XFields, YFields, mulRelationData);
	}
}
